package com.spring.lesson.scope;

import org.junit.Before;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class TestBeanScope {

    private ApplicationContext context;

    @Before
    public void init() {
        System.out.println("===================");
        // XML方式配置
        // context = new ClassPathXmlApplicationContext("application-scope.xml");
        // 使用注解
        context = new ClassPathXmlApplicationContext("application-scope-annotation.xml");
    }


    @Test
    public void testXML() {
        Object object1 = context.getBean("order");
        Object object2 = context.getBean("order");
        System.out.println(object1 == object2);
    }

    @Test
    public void testAnnotation() {
        Object object1 = context.getBean("order");
        Object object2 = context.getBean("order");
        System.out.println(object1 == object2);
    }
}
